package com.ziyucoding.springboot.labs.lab10.seatdemo.tccscfeign.transactionrecordservice.dao;

import com.ziyucoding.springboot.labs.lab10.seatdemo.tccscfeign.transactionrecordservice.dataobject.TransactionalRecordDO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * 事务记录 DAO
 *
 * @author ziyucoding
 * @date 2022-11-06
 **/
@Mapper
@Repository
public interface TransactionalRecordDao {

    /**
     * 保存事务记录
     *
     * @param item
     * @return
     */
    @Insert("INSERT INTO transactional_record (id, xid, status) VALUES (#{id}, #{xid}, #{status})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    Integer saveTransactionalRecord(TransactionalRecordDO item);

    /**
     * 获取事务记录
     *
     * @param xid
     * @return TransactionalRecordDO
     **/
    @Select("SELECT id, xid, status FROM transactional_record WHERE id = #{xid}")
    TransactionalRecordDO findByXid(@Param("xid") String xid);

}
